﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Xml;

namespace PK.Utilities.Configuration
{
    /// <summary>
    /// A configuration element class for text elements
    /// </summary>
    /// <typeparam name="T">The type of the returning text</typeparam>
    /// <example>
    /// For a xml of the form:
    /// <node>value</node>
    /// 
    /// Its posible to extract the inner value on a specific type.
    /// </example>
    public class ConfigurationTextElement<T> : ConfigurationElement
    {
        private T _value;

        protected override void DeserializeElement(XmlReader reader,
                                bool serializeCollectionKey)
        {
            _value = (T)reader.ReadElementContentAs(typeof(T), null);
        }

        /// <summary>
        /// Gets the inner value of the node
        /// </summary>
        public T Value
        {
            get { return _value; }
        }
    }
}
